﻿using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;

namespace TrackIT.UnitTest
{
    [ExcludeFromCodeCoverage]
    public class TestHelper
    {
        public static MemoryStream StringListToStream(List<string> workLogEntries)
        {
            MemoryStream memoryStream = new MemoryStream();
            StreamWriter writer = new StreamWriter(memoryStream);

            foreach (string entry in workLogEntries.Where(s => !string.IsNullOrEmpty(s)))
            {
                writer.WriteLine(entry);
            }

            writer.Flush();

            return memoryStream;
        }

        public static Stream WorkLogEntries_Test1()
        {
            List<string> entries = new List<string>();
            entries.Add("% 2010-11-10");
            entries.Add("% EOL_0037918 08:20 09:30");
            entries.Add("% EOL_STANDUP 09:30 09:45");
            entries.Add("% EOL_0037918 09:45 12:30");
            entries.Add("% EOL_ADMIN 13:45 14:15");
            entries.Add("% EOL_0037918 14:15 18:00");

            MemoryStream workLogStream = new MemoryStream();
            workLogStream = TestHelper.StringListToStream(entries);
            return workLogStream;
        }
    }
}
